﻿<UserControl x:Class="MicroFlasher.Views.Settings.ConnectionView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:models="clr-namespace:MicroFlasher.Models"
             xmlns:converters="clr-namespace:MicroFlasher.Converters"
             xmlns:settings="clr-namespace:MicroFlasher.Views.Settings"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300" d:DataContext="{d:DesignInstance models:FlasherConfig}">
    <UserControl.Resources>
        <converters:EnumToVisibilityConverter x:Key="EnumToVisibilityConverter" />
    </UserControl.Resources>
    <StackPanel Orientation="Vertical">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition />
            </Grid.ColumnDefinitions>

            <Label Grid.Row="1" Grid.Column="0" Target="{Binding ElementName=ProgrammerType}">Programmer</Label>
            <ComboBox Grid.Row="1" Grid.Column="1" x:Name="ProgrammerType"
                  DisplayMemberPath="Value"
                  SelectedValuePath="Key"
                  ItemsSource="{Binding Path=ProgrammerTypes}" 
                  SelectedValue="{Binding Path=ProgrammerType, Mode=TwoWay}">
            </ComboBox>
        </Grid>
        <StackPanel Orientation="Vertical" Visibility="{Binding Path=ProgrammerType, Converter={StaticResource EnumToVisibilityConverter}, ConverterParameter={x:Static models:ProgrammerType.StkV1}}">
            <settings:StkV1SettingsView DataContext="{Binding Path=Stkv1}" />
        </StackPanel>
        <StackPanel Orientation="Vertical" Visibility="{Binding Path=ProgrammerType, Converter={StaticResource EnumToVisibilityConverter}, ConverterParameter={x:Static models:ProgrammerType.ComBitBang}}">
            <settings:ComBitBangSettingsView DataContext="{Binding Path=ComBitBang}" />
        </StackPanel>
    </StackPanel>
</UserControl>
